import java.util.HashMap;
import java.net.*;
import java.io.*;
/**
 * 
 * @author Jeroen en Jesse
 *
 */

public class Request extends HashMap 
{
	private Socket client;
	private MyInputStream input;
	
	/* REQUEST STUFF */
	private String method;
	private String uri;
	private String protocol;
	
	public Request(Socket c)
	{
		this.client = c;
		try
		{
			input = new MyInputStream(c.getInputStream());
			String inputline = input.readLine();
			// parse first line
			if (inputline != null){
				String[] header = inputline.split(" ");
				method = header[0];
				uri = header[1];
				protocol = header[2];
				System.out.println(inputline);
				inputline = input.readLine();
			}
			// print het hele request
			// nu de headers
			while(inputline != null)
			{	
				String s = inputline;
				String[] headers = s.split(":");
				this.put(headers[0], headers[1]);
				System.out.println(inputline);
				inputline = input.readLine();
			}
		}
		catch(IOException ie)
		{
			System.out.println("io error in request.java");
		}
	}
	
	public String getMETHOD()
	{
		return this.method;
	}
	
	
	public String getURI()
	{
		return this.uri;
	}
	public String getVERSION()
	{
		return this.protocol;
	}

}
